<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ADMIN PANEL | Categories</title>
<?php include 'head.php'; ?>
<script src="<?php echo cp_content_url(); ?>js/jquery.jclock-1.2.0.js" type="text/javascript"></script>
<script type="text/javascript">
$(function($) {
    $('.jclock').jclock();
});
$(document).ready(function(){
	$('#add_new_category').click(function(){
		$('#category_new_form').slideToggle();
		var offset=$(this).offset();
		$('#category_new_form').css('top',offset.top+50);
		$('#category_new_form').css('left',offset.left);
	});
});
</script>
</head>
<body>
<div id="main_container">
  <div class="form" style="display:none;position:absolute;background:#ccc;z-index:999;" id="category_new_form" >
    <form action="<?php echo cp_url(); ?>" method="post" class="niceform" enctype="multipart/form-data">
      <input type="hidden" name="page" value="categories" />
      <input type="hidden" name="action" value="new" />
      <?php if(Params::getParam('category_id')){ ?>
      <input type="hidden" name="category_id" value="<?php echo Params::getParam('category_id'); ?>" />
      <?php }else { ?>
      <input type="hidden" name="category_id" value="0" />
      <?php } ?>
      <h2>New Category</h2>
      <fieldset>
        <dl>
          <dt>
            <label for="name">Name:</label>
          </dt>
          <dd>
            <input type="text" name="name" size="54" />
          </dd>
        </dl>
        <dl>
          <dt>
            <label for="description">Description:</label>
          </dt>
          <dd>
            <textarea name="description" id="comments" rows="5" cols="36"></textarea>
          </dd>
        </dl>
        <dl>
          <dt>
            <label for="image">Image:</label>
          </dt>
          <dd>
            <input type="file" name="image" id="upload" />
          </dd>
        </dl>
        <dl class="submit">
          <input type="submit" name="submit" id="submit" value="Save" />
        </dl>
      </fieldset>
    </form>
  </div>
  <?php include 'topbar.php'; ?>
  
  <div class="main_content">
    <?php include 'header.php'; ?>
    <div class="center_content">
      <div class="left_content">
        <?php include 'left.php'; ?>
      </div>
      <div class="right_content">
        <h2>Categories</h2>
        <a href="#" class="bt_green" style="float:left;" id="add_new_category"><span class="bt_green_lft"></span><strong>New Category</strong><span class="bt_green_r"></span></a>
        <?php // print_r($categories); ?>
        <table id="rounded-corner">
          <thead>
            <tr>
              <th scope="col" class="rounded-company">Sort</th>
              <th scope="col" class="rounded">Name</th>
              <th scope="col" class="rounded">Details</th>
              <th scope="col" class="rounded">Image</th>
              <th scope="col" class="rounded">Edit</th>
              <th scope="col" class="rounded-q4">Delete</th>
            </tr>
          </thead>
          <tfoot>
            <tr>
              <td colspan="5" class="rounded-foot-left"><em>Table Footer Description</em></td>
              <td class="rounded-foot-right">&nbsp;</td>
            </tr>
          </tfoot>
          <tbody>
            <?php foreach($categories as $item) {
			if($item->hasSubCategories()){
					$url=cp_url().'?page=categories&category_id='.$item->getCategory_id();
			}else{
				$url=cp_url().'?page=items&category_id='.$item->getCategory_id();
			}
			
			?>
            <tr>
              <td><?php  ?></td>
              <td><a href="<?php echo $url; ?>"><?php echo $item->getName(); ?></a></td>
              <td><?php echo $item->getDescription();;  ?></td>
              <td><img src="<?php echo $item->getImageURI(); ?>" width="50" height="50" /></td>
              <td><a href="<?php echo cp_url(); ?>?page=categories&action=edit&category_id=<?php echo $item->getCategory_id(); ?>"><img src="<?php echo cp_content_url(); ?>images/user_edit.png" alt="" title="" border="0" /></a></td>
              <td><a href="<?php echo cp_url(); ?>?page=categories&action=delete&category_id=<?php echo $item->getCategory_id(); ?>" class="ask"><img src="<?php echo cp_content_url(); ?>images/trash.png" alt="" title="" border="0" /></a></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
        
        <!-- end of right content--> 
        
      </div>
      <!--end of center content -->
      
      <div class="clear"></div>
    </div>
    <!--end of main content-->
    <?php include 'footer.php'; ?>
  </div>
</div>
</body>
</html>